package com.runssnail.huafeiduo.api.request.phone;

import com.runssnail.huafeiduo.api.request.GetRequest;
import com.runssnail.huafeiduo.api.response.phone.OrderPhoneGetResponse;
import org.apache.commons.lang.StringUtils;

import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * 获得单个订单信息，包括状态，可以用这个接口来检查是否完成了充值。

 order_id 和 sp_order_id 至少需要传一个。

 * Created by zhengwei on 2016/3/31.
 */
public class OrderPhoneGetRequest extends GetRequest<OrderPhoneGetResponse> {

    private static final long serialVersionUID = 6582283580155539885L;

    /**
     * 商户订单号
     */
    private String spOrderId;

    /**
     * 话费多订单id
     */
    private String orderId;

    @Override
    public String getApiUrl() {
        return "http://api.huafeiduo.com/gateway.cgi?mod=order.phone.get";
    }

    @Override
    public Map<String, Object> getParams() {
        SortedMap<String, Object> params = new TreeMap<>();

        if (StringUtils.isNotBlank(this.spOrderId)) {
            params.put("sp_order_id", this.spOrderId);
        }

        if (StringUtils.isNotBlank(this.orderId)) {
            params.put("order_id", this.orderId);
        }

        return params;
    }

    @Override
    public Class<OrderPhoneGetResponse> getResponseClass() {
        return OrderPhoneGetResponse.class;
    }

    public String getSpOrderId() {
        return spOrderId;
    }

    public void setSpOrderId(String spOrderId) {
        this.spOrderId = spOrderId;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
}
